package com.qingzhuge.log.autoconfigure;

import com.qingzhuge.log.aspect.SysLogAspect;
import com.qingzhuge.log.event.SysLogListener;
import com.qingzhuge.log.service.ISysLogService;
import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * @author : zero.xiao
 * @description :
 * @date :2019-08-12 14:45
 * @modified :
 * EnableAsync 启用异步任务
 * ConditionalOnWebApplication 当前项目是WEB项目的条件下
 */
@EnableAsync
@EnableAspectJAutoProxy
@Configuration
@AllArgsConstructor
@ConditionalOnWebApplication
public class LogAutoConfiguration {
    @Bean
    public SysLogListener sysLogListener(ISysLogService sysLogService) {
        return new SysLogListener(sysLogService);
    }

    @Bean
    public SysLogAspect sysLogAspect() {
        return new SysLogAspect();
    }
}
